/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package conn.dao;

import AsteriskBean.BCdr;
import AsteriskDao.AsteriskManager;
import java.sql.Statement;
import conn.bean.BAbonado;
import conn.bean.BCampana;
import conn.bean.BDepartamento;
import conn.bean.BDireccion;
import conn.bean.BDistrito;
import conn.bean.BEestadollamada;
import conn.bean.BEmpleado;
import conn.bean.BEstadollamada;
import conn.bean.BLinea;
import conn.bean.BLineaxcampana;
import conn.bean.BLlamada;
import conn.bean.BMensaje;
import conn.bean.BProvincia;
import conn.bean.BTipoLinea;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;



//import com.nw.entity.Employee;

import java.util.ArrayList;
import java.util.List;
//import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.io.PrintStream;

public class DLlamada extends DBase {

   public void nuevallamada(BCdr cdr, int idcampana, String idlinea) {
        Statement stmt = null;
        ResultSet res = null;
       


        this.init_mysql();  // se inicia la conección a la base de datos

        try {

            stmt = conn.createStatement();
            stmt.executeUpdate(""
                    + " INSERT INTO llamada"
                    + " (duracion, fecha, idCampana, idLinea, estado, idEstadoLlamada)"
                    + " VALUES"
                    + " ('" + cdr.getDuracion() + "','" + cdr.getCalldate() + "',"+idcampana+" ," +idlinea+ ", '"+ cdr.getEstado()+ "', 1 )"
                    + "");

            stmt.close();
            conn.close();

        } catch (SQLException ex) {
            System.out.println("SqlException : " + ex.toString());
        } catch (Exception ex) {
            System.out.println("Exception : " + ex.toString());
        } finally {
            if (res != null) {
                try {
                    res.close();
                } catch (SQLException e) {
                    ;
                }
                res = null;
            }
            if (stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException e) {
                    ;
                }
                stmt = null;
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    ;
                }
                conn = null;
            }
        }
    }

    
    }

